﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Liang.DataBase.Model.Entity;
using Liang.DataBase.BLL;

namespace Liang.DataBase.Helper
{
    public static class UserManager
    {
        static UserBLL userBLL = new UserBLL();

        /// <summary>
        /// 获取当前成功登陆的用户
        /// </summary>
        public static sys_user loginedUser { get; set; }

        /// <summary>
        /// 编辑指定用户的密码
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static bool EditPassword(string userId, string password)
        {
            sys_user tmp = FindUserById(userId);
            if (null == tmp)
            {
                return false;
            }

            tmp.password = password;
            return userBLL.Update(tmp, tmp.userId);
        }

        /// <summary>
        /// 查找指定id的用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static sys_user FindUserById(string id)
        {
            return userBLL.FindByID(id);
        }
    }
}
